
using System;
using System.Windows.Forms;

using TestCases.StockData;
using NUnit.Framework;

using CTrading;
//using NUnit.Extensions.Forms.ExampleApplication;
using CStock;
using CUtil.Excel;
using CGraph;
namespace TestCases.UI.Dialogs 
{
	[TestFixture]
	public class ExcelReaderDialogTest : ProgramContext_TestCases
	{
        CStock.ExcelReader excelReader; 

		[SetUp] 
		public void Init() 
		{
			

		}
		[Test] 
		public void Show()
		{
            excelReader = new ExcelReader();
            excelReader.Read_C_book1_xls();

            DemoForm df = new DemoForm();
            df.DataSetExcel = excelReader.DataSetExcel;
            df.ShowDialog();
          
		}
        [Test] 
        public void ShowChartFromExcel()
        {
             if (!this.programContext.IsInitialized)
                this.programContext.ProgramContext_Init(false);
            //have to see if there is a portfolio there and a dataItem, DataClass etc.

            //just brute force:
            //Assert.IsNotNull(this.programContext.Trader_Simulation.Portfolio_Simulation);
            //Assert.IsNotNull(this.programContext.Trader_Simulation.Portfolio_Simulation.DataItem_Selected);
            //Assert.IsNotNull(this.programContext.Trader_Simulation.Portfolio_Simulation.DataItem_Selected.DataClass);
            //Assert.IsNotNull(this.programContext.Trader_Simulation.Portfolio_Simulation.DataItem_Selected.DataClass.QuoteCollection);
            //Assert.IsNotNull(this.programContext.Trader_Simulation.TradeSystem);

            this.programContext.Configuration.IntradayModus = false;
            CStock.ExcelReader excelReader = new ExcelReader();
            if (excelReader.ReadExcelFile_SetDataSet(@"C:\book1.xls"))
            {
                IDataClass dc = excelReader.CreateDataClassAndReadValues("Siemens");
                if (dc != null)
                {
                    ChartWindow chartWindow = new ChartWindow();
                    IDataItem dataItem = new DataItem();
                    dataItem.ID = dc.ID;
                    
                    dataItem.DataClass = dc;
                    this.programContext.TradeEconomy.Portfolio_Selected.DataItem_Selected = dataItem; //.DataClass = DataClass;
                    //plot share
                    chartWindow.Initialize_ChartData(this.programContext, dataItem);
                    //chartWindow.Charts[0].DataItem = dataItem;
                    //chartWindow.Charts[0].Plot_Share(this.programContext.Configuration.IntradayModus);
                    chartWindow.ShowDialog();
                }
            }

        }

		
	}
}
